package sng.modules.view.components.city.state
{
	import flash.geom.Point;
	
	import mx.controls.Alert;
	
	import sng.modules.view.components.city.cursor.CityCursor;
	import sng.modules.view.components.city.cursor.CityCursorManager;
	import sng.modules.view.components.city.logic.City;
	import sng.modules.view.components.city.logic.attachment.BuildingTipManager;
	import sng.modules.view.components.city.logic.unit.BaseBuilding;
	import sng.utils.BuildingUtil;
	import sng.utils.FilterUtil;

	public class BuildState implements IBuildState
	{
		public function BuildState()
		{
		}

		public function setSkin(build:BaseBuilding):void
		{
			build.skin.getMC().gotoAndStop(build.currentDirection);
		}

		public function execute(build:BaseBuilding):void
		{
		}



		/**
		 *鼠标经过
		 *
		 */
		public function doMouseOver(build:BaseBuilding, cityCurrentState:String):void
		{
			if (build.vo.buildingTypeId == BuildingUtil.ROAD_TYPE && (cityCurrentState == "CityNormalState" || cityCurrentState == "CityFriendState"))
				return;
			build.skin.filters=[FilterUtil.getHighLigitFilter()];
			
			// 移动时需要显示 20110717
//			if (build.vo.buildingTypeId == BuildingUtil.ROAD_TYPE)
//				return;
			//BuildingTipManager.getInstance(build.city.tipContainer).showTip(build);

			var tip:BuildingTooltip=new BuildingTooltip();
			var bPoint:Point=new Point(0, 0);
			bPoint=build.skin.localToGlobal(bPoint);
			tip.x=bPoint.x;
			tip.y=bPoint.y-build.skin.height;
			if(tip.y<100) tip.y = 100;
			tip.stop();

			build.currentStrategy.hearBeatStart(tip);
			build.city.tipContainer.addChild(tip);

			tip.buildingNameText.text=build.vo.buildingname;

			//更改指针状态 eason 20110714
			if (cityCurrentState == "CityNormalState")
			{
				//判断是否可升级
				if (build.uVO.buildStep <= build.vo.createStep && build.uVO.buildStep != 0&&build.vo.buildingTypeId != BuildingUtil.FARM_TYPE)
					CityCursorManager.getInstance().setCursor(CityCursor.UPGRADE_CURSOR);
				//判断是否是树
				if (build.vo.buildingTypeId == BuildingUtil.CAPITAL_ASSETS_TYPE)
					CityCursorManager.getInstance().setCursor(CityCursor.CUT_CURSOR);
				//判断是否是农田
				if (build.vo.buildingTypeId == BuildingUtil.FARM_TYPE)
				{
					//播种
					if(build.uVO.currentState==4)
						CityCursorManager.getInstance().setCursor(CityCursor.SOW_CURSOR);
					//收获
					if(build.uVO.currentState==2)
						CityCursorManager.getInstance().setCursor(CityCursor.CUT_CURSOR);
				}

			}


//			build.height = City.HEIGHT_TOP;
		}

		/**
		 *鼠标离开
		 *
		 */
		public function doMouseOut(build:BaseBuilding, cityCurrentState:String):void
		{
			build.skin.filters=[];
			if (build.vo.buildingTypeId == BuildingUtil.ROAD_TYPE&&cityCurrentState=="CityNormalState")
				return;
			//	BuildingTipManager.getInstance().hideTip();

//			build.height = City.HEIGHT_NORMAL;
			if (build.city.tipContainer == null)
				return;
			while (build.city.tipContainer.numChildren > 0)
			{
				build.city.tipContainer.removeChildAt(build.city.tipContainer.numChildren - 1);
			}
			build.currentStrategy.hearBeatEnd();

			if (cityCurrentState == "CityNormalState")
				//更改指针状态 eason 20110714
				CityCursorManager.getInstance().setCursor(CityCursor.NORMAL_CURSOR);

		}

		public function getiStateType():uint
		{
			return 0;
		}
	}
}
